<template>
  <!-- 小药箱 -->
  <section>
    <el-row>
      <el-col :span="6">
        <el-row>
          <span style="font-size: 20px;">家庭小药箱</span>
        </el-row>
        <el-row style="margin-top:40px;">
          <img style="width:120px;" :src="widget.config.qrcode"/>
        </el-row>
      </el-col>
      <el-col :span="18" style="border:1px solid #666;padding:5px;">
        <el-row style="border-bottom: 1px solid #666">
          <div v-html="widget.config.description"></div>
        </el-row>
        <el-row style="font-weight: bold;">
          <el-col :span="6">常见急性情况</el-col>
          <el-col :span="18">处理方法</el-col>
        </el-row>
        <el-row v-for="disease of widget.data.disease" :key="disease.id" style="border-top:1px dashed #666;border-bottom:1px dashed #666;">
          <el-col :span="6">
            <div style="font-weight: bold">{{disease.name}}</div>
            <div>{{disease.description}}</div>
          </el-col>
          <el-col :span="18" style="border-left:1px solid #888">
            <el-row v-for="(m,index) of disease.method" :key="index">
              <div>材料：<span style="padding-right:15px;" v-for="mt of m.materials" :key="mt.name.id">{{mt.name.name}}</span></div>
              <div>制作：{{m.method}}</div>
              <div>用法：{{m.way}}</div>
              <div v-if="index<(disease.method.length-1)" style="padding:10px;"></div>
            </el-row>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
  </section>
</template>

<script>
  export default {
    name: "page-fangan-h",
    props: ['reportData','widget', 'showConfDialog'],
    created(){
      if(Object.getOwnPropertyNames(this.widget.data).length < 2){
        this.widget.data.disease = []
        this.reportData.data.disease.forEach(d=>{
          if(this.isString(d.method)){
            d.method = JSON.parse(d.method)
          }
          this.widget.data.disease.push(d)
        })
        console.log(this.widget.data.disease)
        this.$emit('done',this.widget.data)
      }
    },
    methods:{
      isString(o){
        //console.log(typeof o)
        //console.log(Object.prototype.toString(o))
        return typeof o === 'string'
      }
    }
  }
</script>

<style scoped>

</style>
